package com.xiaoman.jvm.classpath.impl;

import com.xiaoman.jvm.classpath.Entry;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * 目录形式的类路径
 */
public class DirEntry implements Entry {
    private Path absPath;
    public DirEntry (String path) {
        this.absPath = Paths.get(path).toAbsolutePath();
    }
    @Override
    public byte[] readClass(String className) throws IOException {
        return Files.readAllBytes(absPath.resolve(className));
    }

    @Override
    public String String() {
        return this.absPath.toString();
    }
}
